package org.openbpm.bpm.api.constant;

import org.openbpm.base.api.exception.BusinessException;
import org.openbpm.bpm.api.exception.BpmStatusCode;

public enum ActionType {
    DRAFT("draft", "保存草稿", "instanceSaveActionHandler"),
    START("start", "启动", "instanceStartActionHandler"),
    AGREE("agree", "同意", "taskAgreeActionHandler"),
    SIGNAGREE("signAgree", "会签同意", "taskSignAgreeActionHandler"),
    SAVE("save", "保存", "taskSaveActionHandler"),
    OPPOSE("oppose", "反对", "taskOpposeActionHandler"),
    SIGNOPPOSE("signOppose", "会签反对", "taskSignOpposeActionHandler"),
    REJECT("reject", "驳回", "taskRejectActionHandler"),
    REJECT2START("reject2Start", "驳回发起人", "taskReject2StartActionHandler"),
    RECOVER("recover", "撤销", "instanceRecoverActionHandler"),

    REVOKE("revoke", "撤销", "instanceRevokeActionHandler"),
    DISPENDSE("dispense", "分发", "null"),
    TASKOPINION("taskOpinion", "审批历史", "instanceTaskOpinionActionHandler"),
    FLOWIMAGE("flowImage", "流程图", "instanceImageActionHandler"),
    PRINT("print", "打印", "instancePrintActionHandler"),
    MANUALEND("manualEnd", "人工终止", "instanceManualEndActionHandler"),
    INSTANCE_END("instanceEnd", "超管终止", "instanceEndActionHandler"),
    TASK_FREE_JUMP("taskFreeJump", "超管跳转", "taskFreeJumpActionHandler"),
    INSTANCE_RESTART("instanceRestart", "重启实例", "instanceRestartActionHandler"),
    LOCK("lock", "锁定", "taskLockActionHandler"),
    UNLOCK("unlock", "解锁", "taskUnlockActionHandler"),

    TURN("turn", "转办", "taskTurnActionHandler"),
    REMINDER("reminder", "催办", "instanceReminderActionHandler"),
    RECALL("recall", "撤回", "instanceRecallActionHandler"),

    ADDSIGN("addSign", "加签", "addSignActionHandler"),
    ADDDO("addDo", "加办", "addDoActionHandler"),
    ADDDOAGREE("addDoAgree", "处理加办", "addDoAgreeActionHandler"),

    CREATE("create", "创建时", "null"),
    END("end", "流程结束", "null"),
    CLOSE("closeWindow", "返回", "null"),
    TASKCANCELLED("taskCancelled", "任务取消", "null"),
    CARBONCOPY("carbonCopy", "抄送", "carbonCopyActionHandler"),
    SUBMIT("submit", "提交", "taskSubmitActionHandler"),
    AUTOAGREE("autoagree", "自动同意", "taskAutoAgreeActionHandler");

    private String key = "";

    private String name = "";

    private String beanId = "";

    ActionType(String key, String name, String beanId) {
        this.key = key;
        this.name = name;
        this.beanId = beanId;
    }

    public String getKey() { return this.key; }

    public void setKey(String key) { this.key = key; }

    public String getName() { return this.name; }

    public String getBeanId() { return this.beanId; }

    public void setName(String value) { this.name = value; }

    public String toString() { return this.key; }

    public static ActionType fromKey(String key) {
        for (ActionType c : values()) {
            if (c.getKey().equalsIgnoreCase(key))
                return c;
        }
        throw new BusinessException(BpmStatusCode.NO_TASK_ACTION);
    }
}
